<link type="text/css" rel="stylesheet" href="<?php echo $this->basePath('public/css/dbblack/css/ucenter.css'); ?>" />
<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/artdialog/artDialog.js?skin=simple'); ?>"></script>
<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/artdialog/plugins/iframeTools.js'); ?>"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $this->basePath('public/css/dbblack/js/form/style.css'); ?>"/>

<div class="container clearfix">
    <?php echo $this->partial('shopfront/home/left_menu.phtml'); ?>
    <div class="content clearfix uc-content">
        <h1 class="title"><span><?php echo $this->translate('虚拟商品'); ?>：</span></h1>
        <?php if ($this->virtual_goods->getTotalItemCount() > 0) { ?>
            <table class="simple attention">
                <tr>
                    <th width="120"><?php echo $this->translate('商品名称'); ?></th>
                    <th width="120"><?php echo $this->translate('订单编号'); ?></th>
                    <th width="80"><?php echo $this->translate('商品数量'); ?></th>
                    <th width="100"><?php echo $this->translate('操作'); ?></th>
                </tr>
                <?php foreach ($this->virtual_goods as $goods_key => $goods_value) { ?>
                <tr class="<?php echo $goods_key%2==1 ? 'even' : 'odd'; ?>">
                    <td><?php echo $this->escapeHtml($goods_value['goods_name']); ?></td>
                    <td><?php echo $this->escapeHtml($goods_value['order_sn']); ?></td>
                    <td><?php echo $this->escapeHtml($goods_value['buy_num']); ?></td>
                    <td>
                        <?php
                        if($goods_value['order_state'] < 20) echo '<font color="red">'.$this->translate('未付款').'</font>';
                        else {
                            ?>
                            <a href="JavaScript:;" onclick="get_virtual_goods(<?php echo $goods_value['order_id']; ?>, <?php echo $goods_value['goods_id']; ?>);"><?php echo $this->translate('获取商品信息'); ?></a>
                        <?php } ?>
                    </td>
                </tr>
                <?php } ?>
            </table>
            <div class="page-nav"><?php echo ( count($this->virtual_goods) > 0 ) ? $this->paginationControl($this->virtual_goods, 'Sliding', 'site/dbpage',array('page_url'=>$this->url('frontorder/default/order_page', array('action'=>'virtualGoods')))) : ""; ?></div>
            <?php } else { ?>
            <p><?php echo $this->translate('暂无虚拟商品！'); ?></p>
            <?php } ?>
    </div>
</div>

<table class="form" id="virtual-goods-show" style="display: none;margin-bottom: 50px;" novalidate="true">
    <tbody id="virtual-modal-body">
    </tbody>
</table>
<script>
    function get_virtual_goods(order_id, goods_id) {
        $.post("<?php echo $this->url('frontorder/default', array('action'=>'VirtualGoodsInfo')); ?>",{order_id:order_id, goods_id:goods_id},
            function(data){
                if(data.state == 'true') {
                    var i,html = '';
                    var num;
                    for(i=0; i<data.goods.length; i++) {
                        num = i+1;

                       // if(i>0) html += '<hr>';
                        html += '<tr>';
                        html += '<td class="label"><?php echo $this->translate('账号'); ?>('+num+')：</td>';
                        html += '<td>'+data.goods[i].virtual_goods_account+'</td>';
                        html += '</tr>';
                        html += '<tr>';
                        html += '<td class="label"><?php echo $this->translate('密码'); ?>('+num+')：</td>';
                        html += '<td>'+data.goods[i].virtual_goods_password+'</td>';
                        html += '</tr>';

                    }
                    $('#virtual-modal-body').html(html);
                    dlg = dialog({id:'virtual-goods-show',opacity:0.3,padding:'20px 10px 10px 20px',width:900,title:'<?php echo $this->translate('虚拟商品'); ?>',content:document.getElementById('virtual-goods-show'),lock:true});
                    dlg.showModal();
                } else {
                    alert(data.message);
                    return false;
                }
            }, 'json');
    }
</script>